﻿@using Smartstore.Core.Catalog.Attributes

@model ChoiceModel

@{
	var controlId = Model.BuildControlId();
	var label = Model.GetLabel();
	var description = Model.GetDescription();

	var isTextInput = Model.AttributeControlType == AttributeControlType.TextBox || Model.AttributeControlType == AttributeControlType.MultilineTextbox;
	string templateSuffix = null;
	switch (Model.AttributeControlType)
	{
		case AttributeControlType.DropdownList:
		{
			templateSuffix = "Dropdown";
			break;
		}
		case AttributeControlType.Checkboxes:
		case AttributeControlType.RadioList:
		{
			templateSuffix = "CheckRadio";
			break;
		}
		case AttributeControlType.TextBox:
		{
			templateSuffix = "TextBox";
			break;
		}
		case AttributeControlType.MultilineTextbox:
		{
			templateSuffix = "TextArea";
			break;
		}
		case AttributeControlType.Datepicker:
		{
			templateSuffix = "Date";
			break;
		}
		case AttributeControlType.FileUpload:
		{
			templateSuffix = "FileUpload";
			break;
		}
		case AttributeControlType.Boxes:
		{
			templateSuffix = "Box";
			break;
		}
	}
}

<div class="form-group choice">
    <label class="choice-label@(Model.IsRequired ? " required" : "")" for="@controlId">@label</label>
    <div sm-if="!isTextInput && description.HasValue()" class="choice-description">
        @Html.Raw(description)
    </div>
    <div class="choice-control">
		<partial name="@("ChoiceTemplates/Choice." + templateSuffix)" model="Model" />
    </div>
</div>